<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全科信息系统极简版</title>
    <link rel="shortcut icon" href="/xh_logo.ico">
    <%@include file="/common/jscss.jsp" %>
    <base target="_self">
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

    <style>

        body {
            /*display: flex;*/
            /*align-items: center;*/
            padding-top: 3%;
        }

        #logo {
            padding-left: 50px;
            background: url("../../../img/logo.jpg") 0 0 no-repeat;
            background-size: 48px;
            color: #1d89db;
            margin-left: 120px;
        }

        #logo h1 {
            margin-bottom: 0;
        }

        #logo h4 {
            margin-top: 0;
        }

        #cont {
            background: url("../../../img/bg372.png") 0 0 no-repeat;
            background-size: 100%;
            padding: 50px 0;
            width: 100%;
            min-width: 1250px;
        }

        #login_box {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            width: 950px;
            margin: 0 auto;

        }

        #login_box h1 {
            font-size: 40px;
        }

        #login_box > div b, #login_box > div > h2 {
            color: #ffffff;
            letter-spacing: 1px;
        }

        #login_box form {
            width: 35%;
            background-color: #ffffff;
        }

        form > div {
            border-top: 2px solid #1d89db;
            padding: 40px 20px;
            box-shadow: 0 4px 60px -1px rgba(171, 171, 171, 0.46);
        }

        #login_box h2 {
            margin-top: 0;
        }

        #login_box form button {
            background-color: #1d89db;
            color: #ffffff;
        }

        #login_box .form-group {
            position: relative;

        }

        #login_box .form-group i {
            position: absolute;
            left: 0;
            top: 0;
            height: 34px;
            line-height: 34px;
            background-color: #46abf3;
            font-size: 20px;
            color: #ffffff;
            width: 35px;
            text-align: center;
        }

        #login_box .form-group input {
            padding-left: 40px;
        }

        .input-code {
            width: calc(100% - 96px);
        }

        #get-code {
            width: 96px;
            position: absolute;
            right: 0;
            top: 0;
            border-radius: 0;
        }

        .btns {
            position: relative;
            text-align: right;
            margin-top: 25px;
        }

        #returnBtn {
            position: absolute;
            left: 0;
            top: 0;
            color: #46abf3;
            border-color: #46abf3;
        }
    </style>
</head>

<body>

<div id="logo">
    <h1><b>广东省家庭医生协会</b></h1>
    <h4>GUANGDONG FAMILY DOCTOR ASSOCIATION</h4>
</div>

<div id="cont">
    <div id="login_box" class="animated fadeInDown">
        <div>
            <h1><b>欢迎使用全科信息系统极简版</b></h1>
            <h2>广东省家庭医生协会</h2>
        </div>

        <form role="form" id="form" action="${ctx }/admin/modifyPassword" method="post">

            <div>
                <h2>忘记密码</h2>
                <div class="form-group">
                    <i class="fa fa-mobile"></i>
                    <input type="text" id="phone" name="phone" class="form-control" placeholder="请输入手机号"
                           maxlength="11" required>
                </div>
                <div class="form-group">
                    <i class="fa fa-envelope"></i>
                    <input type="text" name="code" id="code" class="form-control input-code" placeholder="请输入验证码" required>
                    <button type="button" class="btn btn-code" id="get-code" onclick="getCode()">获取验证码</button>
                </div>
                <div class="form-group">
                    <i class="fa fa-key"></i>
                    <input type="password" id="password" name="password" class="form-control" placeholder="请输入新密码" autocomplete="new-password" required>
                </div>
                <div class="btns">
                    <a href="${ctx}/admin/login" class="btn btn-outline" id="returnBtn">返回登录</a>
                    <button type="button" class="btn" onclick="modifyPwd()">修改密码</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

    function getCode(){
        $.ajax({
            url: "${ctx}/admin/sendSmsVCode",
            data: {
                phone: $('#phone').val()
            },
            success: function(data) {

                var _data = JSON.parse(data);
                if (isSuccess(_data)) {
                    var time = 60;
                    $("#get-code").html(time)
                        .prop("disabled", true);
                    var t = setInterval(function () {
                        if (time > 0) {
                            time--;
                            $("#get-code").html(time);
                        } else {
                            $("#get-code").html('获取验证码')
                                .prop("disabled", false);
                            clearInterval(t);
                            time = 60;
                        }
                    }, 1000)
                }else {
                    error(_data.msg);
                }
            }
        });
    }

    function modifyPwd() {
        $.ajax({
            url: "${ctx}/admin/modifyPassword",
            data: {
                phone: $('#phone').val(),
                code: $('#code').val(),
                password: $('#password').val()
            },

            success: function(data) {

                var _data = JSON.parse(data);
                if (isSuccess(_data)) {
                    location.replace("${ctx}/admin/login");
                }else {
                    error(_data.msg);
                }
            }
        });
    }
</script>
</body>

</html>